package com.xiaoyg.algorithm;

import java.util.Stack;

public class StackQueue {
    public Stack<Integer> inStack = new Stack<>();
    public Stack<Integer> outStack = new Stack<>();
    public int peek(){
        if (outStack.isEmpty()){
            inToOut();
        }
        return outStack.peek();
    }
    private void inToOut() {
        while (!inStack.isEmpty()){
            outStack.push(inStack.pop());
        }
    }
    public void push(int element){
        inStack.push(element);
    }
    public int pop(){
        if (outStack.isEmpty()){
            inToOut();
        }
        return outStack.pop();
    }
    public boolean isEmpty(){
        return inStack.isEmpty() && inStack.isEmpty();
    }
}
